<template>
	<view>
		<view class="header-top">
			<image class="topbg" src="../../static/minebg.png" mode=""></image>
			<view class="header-inner fa" :style="{paddingTop: utils.menuButtonTop(), height: utils.menuButtonHeight(), background: opacity}">
				<view class="header-title">个人中心</view>
			</view>
			<view class="header-place" :style="{paddingTop: utils.menuButtonTop(), height: utils.menuButtonHeight()}"></view>
		</view>
		<view class="main pr">
			<view class="user-box fa" @click="utils.navTo('/pages/mine/userinfo')">
				<image class="avatar" :src="avatar" mode=""></image>
				<view>
					<view class="nickname">{{name}}</view>
					<view class="mobile">{{phone}}</view>
				</view>
			</view>
			<view class="order-wrapper pr">
				<image class="mineorder" src="../../static/mineorder.png" mode=""></image>
				<view class="order-inner pr flex fdc jcsb">
					<view class="order-top fa jcsb">
						<view>
							<view class="name">总订单</view>
							<view class="count">{{all}}</view>
						</view>
						<view class="view-more theme" @click="utils.navTo('/pages/mine/work_stat')">查看更多</view>
					</view>
					<view class="order-bottom fa">
						<view class="order-list" @click="utils.navTo('/pages/mine/work_stat')">
							<view class="name">今日订单</view>
							<view class="count">{{todayCount}}</view>
						</view>
						<view class="order-list" @click="utils.navTo('/pages/mine/work_stat')">
							<view class="name">本周订单</view>
							<view class="count">{{weekCount}}</view>
						</view>
						<view class="order-list" @click="utils.navTo('/pages/mine/work_stat')">
							<view class="name">本月订单</view>
							<view class="count">{{monthCount}}</view>
						</view>
					</view>
				</view>
			</view>
			<view class="site-box">
				<view class="site-list fa jcsb" @click="utils.navTo('/pages/mine/userinfo')">
					<view class="fa">
						<image class="site-icon" src="../../static/mine1.png" mode=""></image>
						<view>我的资料</view>
					</view>
					<image class="right-icon" src="../../static/right.png" mode=""></image>
				</view>
				<view class="site-list fa jcsb" @click="utils.navTo('/pages/mine/comment')">
					<view class="fa">
						<image class="site-icon" src="../../static/mine2.png" mode=""></image>
						<view>我的评价</view>
					</view>
					<image class="right-icon" src="../../static/right.png" mode=""></image>
				</view>
				<view class="site-list fa jcsb" @click="utils.navTo('/pages/mine/feedback')">
					<view class="fa">
						<image class="site-icon" src="../../static/mine3.png" mode=""></image>
						<view>投诉建议</view>
					</view>
					<image class="right-icon" src="../../static/right.png" mode=""></image>
				</view>
				<view class="site-list fa jcsb" @click="utils.navTo('/pages/mine/service')">
					<view class="fa">
						<image class="site-icon" src="../../static/mine4.png" mode=""></image>
						<view>联系客服</view>
					</view>
					<image class="right-icon" src="../../static/right.png" mode=""></image>
				</view>
				<view class="site-list fa jcsb" @click="utils.navTo('/pages/mine/settings')">
					<view class="fa">
						<image class="site-icon" src="../../static/mine5.png" mode=""></image>
						<view>设置</view>
					</view>
					<image class="right-icon" src="../../static/right.png" mode=""></image>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				avatar: '../../static/avatar.png',
				name: '',
				phone: '',
				all: 0,
				todayCount: 0,
				weekCount: 0,
				monthCount: 0
			};
		},
		onLoad() {
			
		},
		onShow() {
			this.getUserinfo()
		},
		onPullDownRefresh() {
			setTimeout(() => {
				this.getUserinfo()
				this.getOrderCount()
				uni.stopPullDownRefresh()
			}, 1000)
		},
		methods: {
			getUserinfo() {
				this.api.userinfoFunc().then(res => {
					if(res.code == 200) {
						this.avatar = res.data.avatar
						this.name = res.data.name
						this.phone = res.data.phone
						this.getOrderCount()
					}else {
						this.avatar = '../../static/avatar.png'
						this.name = '未登录'
						this.phone = ''
					}
				}).catch(err => {
					this.avatar = '../../static/avatar.png'
					this.name = '未登录'
					this.phone = ''
				})
			},
			getOrderCount() {
				this.api.orderCountFunc().then(res => {
					if(res.code == 200) {
						this.all = res.data.all
						this.todayCount = res.data.todayCount
						this.weekCount = res.data.weekCount
						this.monthCount = res.data.monthCount
					}
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	.header-top{
		.topbg{
			position: fixed;
			top: 0;
			width: 100%;
		}
		.header-inner{
			position: fixed;
			z-index: 999;
			left: 0;
			right: 0;
			padding-bottom: 16rpx;
			padding-left: 40rpx;
			padding-right: 40rpx;
			.header-title{
				position: absolute;
				left: 200rpx;
				right: 200rpx;
				text-align: center;
				font-size: 34rpx;
			}
		}
		.header-place{
			padding-bottom: 16rpx;
		}
	}
	.user-box{
		margin: 26rpx 28rpx 0;
		.avatar{
			margin-right: 24rpx;
			width: 110rpx;
			height: 110rpx;
			border-radius: 50%;
		}
		.nickname{
			margin-top: 12rpx;
			font-size: 30rpx;
			font-weight: bold;
			line-height: 36rpx;
		}
		.mobile{
			margin-top: 10rpx;
			font-size: 24rpx;
			line-height: 28rpx;
		}
	}
	.order-wrapper{
		margin: 36rpx 28rpx 0;
		height: 326rpx;
		background-color: #fff;
		.mineorder{
			position: absolute;
			top: 0;
			left: 0;
			right: 0;
			width: 100%;
			height: 100%;
		}
		.order-inner{
			height: 100%;
			.order-top{
				padding: 32rpx 48rpx 0 56rpx;
				.name{
					font-size: 24rpx;
					color: #fff;
					line-height: 28rpx;
				}
				.count{
					margin-top: 6rpx;
					font-size: 56rpx;
					color: #fff;
					line-height: 66rpx;
				}
				.view-more{
					padding: 0 36rpx;
					height: 68rpx;
					line-height: 68rpx;
					border-radius: 10rpx;
					font-size: 26rpx;
					font-weight: bold;
					background: linear-gradient(90deg, rgba(255, 255, 255, 1), rgba(255, 255, 255, .75));
				}
			}
			.order-bottom{
				padding: 0 40rpx 48rpx;
				padding-left: 40rpx;
				padding-bottom: 28rpx;
				.order-list{
					flex: 1;
					.name{
						font-size: 24rpx;
						color: #777;
					}
					.count{
						margin-top: 6rpx;
						font-size: 40rpx;
						font-weight: bold;
						line-height: 46rpx;
					}
				}
			}
		}
	}
	.site-box{
		margin: 24rpx 28rpx;
		padding: 0 28rpx;
		border-radius: 24rpx;
		background-color: #fff;
		.site-list{
			padding: 26rpx 0;
			.site-icon{
				margin-right: 28rpx;
				width: 48rpx;
				height: 48rpx;
			}
			.right-icon{
				width: 28rpx;
				height: 28rpx;
			}
		}
	}
</style>
